package cjq.demo.thread.ch4_11;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2016/5/1.
 */
public class ReportGenerator implements Callable<String> {
    private String sender;
    private String title;

    public ReportGenerator(String sender,String title){
        this.sender = sender;
        this.title = title;
    }

    public String call() throws Exception {
         try{
             long duration = (long) (Math.random()*10);
             System.out.println(this.sender+"_"+this.title+" ReportGenerator: Generating a report during "+duration+" seconds ");
             TimeUnit.SECONDS.sleep(duration);
         }catch(InterruptedException e){
             e.printStackTrace();
         }
        String ret = sender + " : "+ title;
        return ret;
    }

}
